package com.sskj.spk.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.spk.http.HttpConfig;
import com.sskj.spk.ui.activity.MarketNewActivity;
import com.sskj.lib.bean.StockCoinBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;


public class MarketNewActivityPresenter extends BasePresenter<MarketNewActivity> {
    /**
     * 获取股票最新数据
     *
     * @param
     * @param code 编码
     */
    public void getNewInfo(String code) {
        httpService.getProduct(code)
                .execute(new JsonCallBack<HttpData<List<StockCoinBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<StockCoinBean>>> response) {
                        HttpData<List<StockCoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            if (httpData.getData() != null) {
                                if (httpData.getData().size() > 0) {
                                    mView.updateUI(httpData.getData().get(0));
                                }
                            }
                        }
                    }
                });
    }
}
